package cn.dubito.manager.error;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorViewResolver;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author liliang
 * @description:
 * @date 2018/5/25.
 */
@Configuration
public class ErrorConfiguration {

    @Bean
    public MyErrorController errorController(ErrorAttributes errorAttributes,
                                             ServerProperties serverProperties,
                                             ObjectProvider<List<ErrorViewResolver>> objectProperty) {
        return new MyErrorController(errorAttributes,serverProperties.getError(),objectProperty.getIfAvailable());
    }
}
